function ajax(url, param,  async= true,mode = 99) {
    // 校验用户存在
    validateUser();
    $.ajax({
        type: "post",
        dataType: 'json',
        url: url,
        data: JSON.stringify(param),
        contentType: "application/json;charset=UTF-8",
        cache: false,
        async: async,
        success: function (data) {
            switch (mode) {
                case 1:
                    addResult(data);
                    break;
                case 2:
                    dropdownVersionList(data);
                    break;
                case 3:
                    publishResult(data);
                    break;
                case 4:
                    dropdownBaseServerList(data);
                    break;
                case 5:
                    restartServiceResult(data);
                    break;
                default:
                    simpleResponse(data);
                    break
            }
        }
    });
}
function restartServiceResult(data) {
    console.log("重启返回结果")
    console.log(data);
    if (SUCCESS === data.RSPCD) {
        errorMsg("重启成功", type.SUCCESS);
        silenceRefresh("restartList");
    } else {
        errorMsg(data.RSPMSG, type.DANGER)
    }
}
function dropdownBaseServerList(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER)
        return;
    }
    let baseServerList = data.BODY.LIST;
    let append = "";
    for (it of baseServerList) {
        append += "<option value=\"" + it.ID + "\">" + it.NAME + "(" + it.DESC + ")</option>";
    }
    $("#scan_form select[name=scan_server]").html(append);
}

function publishResult(data) {
    console.log("发布响应结果")
    console.log(data)
    if (SUCCESS === data.RSPCD) {
        errorMsg("发布成功", type.SUCCESS);
        $("#myModal").modal("hide");
        silenceRefresh("restartList")
        showAdd();
    } else {
        errorMsg(data.RSPMSG,type.DANGER)
    }
}

function dropdownVersionList(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER)
        return;
    }
    versionList = data.BODY.LIST;
}